﻿namespace PillBox.Client.ViewModels
{
    using System.Collections.Generic;
    using System.ComponentModel.Composition;
    using PillBox.Client.Framework;
    using PillBox.Client.Model;

    [Export]
    public class NotesViewModel : ViewModelBase
    {
        public IEnumerable<Note> Notes
        {
            get;
            set;
        }

        public override void Activate()
        {
            ResultEnumerator.Begin(this.LoadNotes());
        }

        private IEnumerable<IResult> LoadNotes()
        {
            var query = new GetNotesQuery().AsResult();

            yield return query;

            this.Notes = query.Response;

            RaisePropertyChanged(() => Notes);
        }
    }
}